package com.action;

import javax.servlet.http.*;

import org.apache.struts.action.*;

import com.model.RegistrationForm;


public class RegistrationAction extends Action
{

	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
	{
		
		RegistrationForm regForm = (RegistrationForm)form;
		
		String username = regForm.getUsername();
		String email = regForm.getEmail();
		String password = regForm.getPassword();
		
		
		if(email.contains("@") && email.contains(username))
		{
			request.setAttribute("message", "Registration Successful for username : " + username);
			return mapping.findForward("success");
		}
		else
		{
			request.setAttribute("errorMessage", "Registration Failed [ username must be in same format of email ]");
			return mapping.findForward("error");
		}
		
	}
	
}
